/**
 * 刷新用户 将用户信息更新到redis中
 */

import { Button} from 'antd';
import React, { useState } from 'react';
import axios from 'axios'


const RefreshUser = (props) => {

  const [ setIsModalOpen] = useState(false);
  const showModal = () => {
    //生命头文件
    let config = {headers:{'Content-Type':'multipart-/form-data'},withCredentials:true}
    //进行后台请求
    axios({
      method:'POST',
      url:'http://localhost/mall-basic-service/basic/user/getRefreshUser'
    },config).then((response)=>{
      //判断如果成功跳转到登录界面
      const code = response.data.code
      if(code === 200){
        setIsModalOpen(false);
        window.location.reload()
      }
    }).catch(function (error) {
      //处理异常数据
    })
  };

  return (
    <div className={'refreshButDiv'}>
      <Button onClick={showModal}>
        刷新
      </Button>
    </div>
  )
};
export default RefreshUser;
